home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue17 / source / PXDecal.sl < prev    next >
Encoding:
Text File  |  2002-08-14  |  1.3 KB  |  43 lines

  1. /*  AutoShade v2.0 default Surface shader for TCOORD option of C:RMPROP.  */
  2.  
  3. /*  decal.sl     1.0     Larry Knott     06/04/90    */
  4.  
  5. /*  Modified, 10/22/90, KDM
  6.         Changed the default value of one or more parameters to make the
  7.         shader easy to use with the Pushpins filmroll.  */
  8.             
  9.  
  10. /*----------------------------------------------------------------------------
  11.  * decal - texture-map shader
  12.  *
  13.  * Puts a texture map onto a surface using texture coordinates (s, t).
  14.  *
  15.  * texname - the name of the texture file
  16.  * Ka, Kd, Ks, roughness, specularcolor - the usual meaning
  17.  *---------------------------------------------------------------------------*/
  18.  
  19. surface
  20. PXDecal(
  21.       float  Ka = 0.2,            /* Previously = 1 */
  22.              Kd = 0.5,            /* Previously = 1 */
  23.              Ks = 0.4,            /* Previously = 0 */
  24.              roughness = 0.25;
  25.       color  specularcolor = 1;
  26.       string texturename = "";
  27.      )
  28.  
  29. {
  30.     varying vector Nf, NI;
  31.  
  32.     Nf = faceforward( normalize(N), I);
  33.  
  34.     Ci = (Ka*ambient() + Kd*diffuse(Nf)) * color texture(texturename, s, t);
  35.     if (Ks != 0.0)
  36.     {
  37.         NI = normalize(-I);
  38.         Ci += Ks*specularcolor*specular(Nf,NI,roughness);
  39.     }
  40.     Oi = Os;
  41.     Ci = Ci * Oi;
  42. }
  43.